//
//  FirmwareHomeCell.swift
//  DaRings
//
//  Created by 易先生 on 2022/10/31.
//

import UIKit
import MYModule

open class FirmwareHomeCell: TableViewCell {

    open override func makeUI() {
        super.makeUI()
        
        contentView.backgroundColor = UIColor.background

        contentView.addSubview(titleLabel)
        contentView.addSubview(lineView)
        contentView.addSubview(brage)
        contentView.addSubview(iconImageView)

        lineView.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(20)
            make.trailing.equalToSuperview().offset(-20)
            make.height.equalTo(1)
            make.bottom.equalToSuperview()
        }
    
        titleLabel.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(16)
            make.leading.equalToSuperview().offset(20)
        }

        iconImageView.snp.makeConstraints { make in
            make.trailing.equalToSuperview().offset(-20)
            make.centerY.equalToSuperview()
        }
        
        brage.snp.makeConstraints { make in
            make.left.equalTo(titleLabel.snp.right).offset(5)
            make.size.equalTo(6)
            make.bottom.equalTo(titleLabel.snp.top)
        }
    }
    
    public func bind(to cellModel: FirmwareAction) {
        titleLabel.text = cellModel.title
        guard cellModel == .upgrade else {
            lineView.isHidden = false
            return
        }
        lineView.isHidden = true
    }
    
    private lazy var iconImageView: ImageView = {
        let iconImageView = ImageView()
        iconImageView.image = UIImage(named: "ic_next_continue")?.setupImageTintColor(tintColor: UIColor.assist_D0D0D0)
        return iconImageView
    }()
    
    public lazy var brage: View = {
        
        let brage = View()
        brage.backgroundColor = UIColor.subTheme
        brage.cornerRadius = 3.0
        return brage
        
    }()
    
    public lazy var titleLabel: Label = {
        let titleLabel = Label()
        titleLabel.textColor = UIColor.assist_222222
        titleLabel.numberOfLines = 0
        titleLabel.font = Fonts.systemFont(ofSize: 16)
        return titleLabel
    }()

    public lazy var lineView: View = {
        let lineView = View()
        lineView.backgroundColor = UIColor.assist_D0D0D0
        return lineView
    }()

    open override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
